home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
spawno30.zip
/
SPAWNO.DOC
< prev
next >
Wrap
Text File
|
1990-11-16
|
8KB
|
184 lines
SPAWNO v3.0 11/16/90 disk/EMS/XMS swapping replacement for spawn()
(c) Copyright 1990 Ralf Brown. All Rights Reserved.
LICENSE
This document and the associated header file, libraries, and object
modules may be freely copied provided that:
1) all of the files are copied as a group (such as in a single
archive). See below for a list of files.
2) the files are not modified in any way (including removal or
alteration of copyright notices or this license)
3) no charge beyond a cost-recovery fee not to exceed $5 is made
I would appreciate a brief mention in your documentation if you
distribute a program which incorporates SPAWNO.
DISCLAIMER
Although both I and others have tested the code which comprises SPAWNO,
it is entirely possible that SPAWNO may malfunction in environments or
under circumstances in which it has not been tested. This code is
provided AS IS, and the author disclaims any and all responsibility for
damages (both consequential and incidental) resulting from the use or
misuse of SPAWNO. Sole responsibility for determining the suitability
of the code rests with the user.
-----------------
FILES
The disk or archive you received should contain the following files:
SPAWNO.DOC this file
SPAWNO.H the header file providing prototypes for the functions
SPAWN_TC.ZIP archive containing Turbo C/C++ versions of the
libraries SPAWNx.LIB for each of [T]iny, [S]mall,
[C]ompact, [M]edium, and [L]arge memory models.
SPAWN_MS.ZIP archive containing SPAWNx.LIB for Microsoft C
*.C source for the spawn...o() functions
SPAWNPTH.ASM source for the path search
(sorry, I'm not releasing source for the actual swapper at this time)
-----------------
INSTRUCTIONS
Include the header file SPAWNO.H (after PROCESS.H if you include that
file). Then use the functions provided in this archive--spawnvo(),
spawnlo(), spawnvpo(), etc--as you would the corresponding spawnv(),
spawnl(), etc, except replace the first argument by a string containing
the path where the swap file is to be stored. Note that the swap file
path is required even when swapping to XMS or EMS, as SPAWNO will swap
to disk anyway if there is not enough XMS or EMS memory available.
The spawn?p?o() functions search for both .COM and .EXE files in the
current directory and then in the pathed directories if no extension is
given, but use the specified extension if present. If a full pathname
is given to those functions, only the specified directory is searched.
If you define the preprocessor macros REPLACE_SPAWN and OVERLAY_PATH
before #including SPAWNO.H, you should be able to use these functions
with existing code with minimal changes. See SPAWNO.H for more details.
When linking, you must include SPAWNx.LIB. A sample TCC line would
be
tcc -mc <other-flags> sample spawnc.lib library.lib
This results in 448 bytes (disk/XMS) or 464 bytes (EMS) remaining in
memory while the spawned program executes. However, if you want to keep
an interrupt hooked which might be invoked while spawned, you must set
__spawn_resident large enough that *all* code and data which could be
invoked by that interrupt is kept resident[1]. You must also ensure
that none of the code used by interrupt handlers while spawned is
located in the first 224 bytes of the executable (which are temporarily
destroyed while spawning). SPAWNO automatically deactivates INT 23h and
INT 24h and restores them before returning to the caller.
Note: there are two separate sets of libraries, one for Turbo C/C++ (in
the archive SPAWN_TC.ZIP), the other for Microsoft C (in SPAWN_MS.ZIP).
Extract only the version you need, as both sets of files have the same
names.
[1] Due to the segment layout used by C compilers, this option is probably
useful only when calling SPAWNO from assembly-language code (which can
localize such code and data near the start of the executable) or a
small program which uses a large amount of space in the far heap.
-----------------
LIMITATIONS
The Turbo C version of SPAWNO only swaps out the memory block initially
allocated to the program. If you cause additional memory blocks to be
allocated (such as with allocmem()), the additional blocks are not
swapped out. In that case, you will need to use the Microsoft C version
of SPAWNO, which does swap out all memory blocks belonging to the
program. Note that while the Microsoft version works correctly with
Turbo C, the errno variable will not be set to the proper symbolic
constant on error (though it will be nonzero). The Microsoft version of
SPAWNO will increase the size of the executable by about 1K compared to
the Turbo C version.
If the program's environment is large enough that the copy DOS makes
will overwrite the entire code segment and the initialized data segment,
SPAWNO will probably fail, as the name of the program to spawn could be
overwritten before DOS uses it. This should not be a problem in
practice, since a program small enough that it is likely to encounter an
environment large enough to cause the problem won't gain much from
SPAWNO anyway.
There is a chance that this code will not work under the upcoming MSDOS 5,
as it assumes that DOS does not store any internal information beyond offset
3Fh in the PSP (versions through 4.02 do not store data beyond offset 3Bh).
-----------------
SUPPORT
Since I am not getting any money, I can't promise any support. I have
too much to do as it is....
-----------------
ACKNOWLEDGEMENTS
Thanks to Gene McManus for testing the Microsoft version of SPAWNO 3.0.
-----------------
Functions:
int spawnvo(const char *overlay_path, const char *name,
const char **args) ;
int spawnvpo(const char *overlay_path, const char *name,
const char **args) ;
int spawnveo(const char *overlay_path, const char *name,
const char **args,const char **env) ;
int spawnvpeo(const char *overlay_path, const char *name,
const char **args,const char **env) ;
int spawnlo(const char *overlay_path, const char *name, ...) ;
int spawnlpo(const char *overlay_path, const char *name, ...) ;
int spawnleo(const char *overlay_path, const char *name, ...) ;
int spawnlpeo(const char *overlay_path, const char *name, ...) ;
Global variables:
char __spawn_xms ; /* 0 = don't use XMS memory for swapping */
/* 1 = use XMS if available */
/* (default 1) */
char __spawn_ems ; /* 0 = don't use EMS memory for swapping */
/* 1 = use EMS if available and no XMS */
/* (default 1) */
unsigned __spawn_resident ; /* number of paragraphs to keep resident */
/* while in the child program */
/* (default 0 = minimum possible) */
External functions called by SPAWNO:
void *malloc(int) ;
void free(void *) ;
int strlen(char *) ;
int pascal __IOERROR(int) ; /* Turbo C only--internal run-time func */
External variables used by SPAWNO:
int errno ;
int _doserrno ;
unsigned int _psp ;
Other:
SPAWNO version overwrites the PSP, so the commandline will
be lost unless it was copied before the first spawn().
-----------------
Send comments, bug reports, etc. to
Internet: ralf@cs.cmu.edu
Fidonet: Ralf Brown 1:129/3.1 (or post to DR_DEBUG--I can't reply to
netmail from outside Zone 1 at this time)
or
Ralf Brown
School of Computer Science
Carnegie Mellon University
Pittsburgh, PA 15213-3890